import katexAutoRender from "katex/dist/contrib/auto-render"


export function katexString(str) {
    let e = document.createElement('div')
    if (typeof str === Object) {
        e.appendChild(str)
    }

    if (typeof str === 'string') {
        e.innerHTML = str
    }
    katexAutoRender(e, {
        delimiters: [
            {
                left: "$$",
                right: "$$",
                display: true,
            },
            {
                left: "$",
                right: "$",
                display: false,
            },
            {
                left: "\\[",
                right: "\\]",
                display: true,
            },
            {
                left: "\\(",
                right: "\\)",
                display: false,
            },
        ],
        throwOnError: true,
    });
    return e.innerHTML
}
